package myfamily;

import myfamily.model.*;

import javax.jdo.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.io.InputStream;
import java.io.IOException;

public class InsertData {

	public static void main(String[] args) {        
		
		DatabaseObject db = DatabaseObjectFactory.getDatabaseObject();	
		
		//insertDummyData();
		printAllProfiles();
		
		db.pm.close();

	}

	public static void insertDummyData()
	{
		SimpleDateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    	dfm.setTimeZone(TimeZone.getTimeZone("Europe/Zurich"));
    	Date dob = null;

		try {
			dob = dfm.parse("1960-01-23 20:15:00");
		} catch (ParseException e) {
		}


    	Name n = new Name("VijayaKumar", "", "Joseph");
    	Name m = new Name("Lalith","","Nimayini");
    	Name v = new Name("Vineet","Kumar","Joseph");
    	Name t = new Name("Joseph","","A");
    	Name k = new Name("Karan","","Joseph");
    	Name s = new Name("Shashikala","","Meenakumari");
    	Name r = new Name("Raju", "", "BJE");

    	
    	
    	try{
    	
    	RegisteredUser nana = new RegisteredUser("dad", "dad", "123", n, "male" , "Christian", "Indian", dob, null, null);
    	RegisteredUser mum = new RegisteredUser("mum","mum", "123", m, "female", "Christian", "Indian", dob, null , null);
    	RegisteredUser vin = new RegisteredUser("Vin1","Vin1", "123", v, "male", "Christian", "Indian", dob, null, null);
    	RegisteredUser raju = new RegisteredUser("raj", "raj", "123", r, "male", "Christian", "Indian", dob, null, null);
    	RegisteredUser kar = new RegisteredUser("kar","kar", "123", k, "male", "Christian", "Indian", dob, null, null);
    	RegisteredUser sha = new RegisteredUser("sha","sha", "123", s, "female", "Christian", "Indian", dob, null, null);
    	RegisteredUser tat = new RegisteredUser("tat", "tat","123",t,"male", "Christian", "Indian", dob, null, null);
    	GenericPerson sug = nana.createUnregisteredUser(new Name("Suguna", "", "Joseph"), "female", "Christian", "Indian", dob, null, null);

    	
/*    	nana.persist();
    	mum.persist();
    	vin.persist();
    	tat.persist();
    	raju.persist();
    	sha.persist();
    	kar.persist();
    	sug.persist();
*/

    	nana.addChild(mum, vin);

    	tat.addChild(sug, sha);
    	sha.addSpouse(raju);
    	sha.addChild(raju, kar);

    	System.out.println(nana.toString());
    	System.out.println(mum.toString());
    	System.out.println(vin.toString());
    	System.out.println(tat.toString());
    	System.out.println(raju.toString());
    	System.out.println(sha.toString());
    	System.out.println(kar.toString());

    	//nana.addSibling(sha,nana);
    	sha.addSibling(nana, sha);

    	System.out.println();
    	System.out.println();
    	System.out.println();
    	System.out.println(nana.toString());
    	System.out.println(mum.toString());
    	System.out.println(vin.toString());
    	System.out.println(tat.toString());
    	System.out.println(raju.toString());
    	System.out.println(sha.toString());
    	System.out.println(kar.toString());
    	System.out.println(sug.toString());   
    	
    	}
    	catch(Exception e){
    		System.out.println("Some error occurred");
    	}
    	
	}
	
	public static void printAllProfiles()
	{
			
			RegisteredUser ru = RegisteredUser.login("AItOawmg-rK5NRWyGiTozeVWxcsi0RVf3AWddd4");
			System.out.println(ru.getPersonName().toString());
			
	}
	

}
